{% load staticfiles %}
<!DOCTYPE html>
<html>
<head>
    <title>{% block title %}{% endblock %}</title>
    <link href="{% static "css/base.css" %}" rel="stylesheet">
</head>
<body>
<div id="header">
    <span class="logo">Bookmarks</span>
    {% if request.user.is_authenticated %}
        <ul class="menu">
            <li {% if section == "dashboard" %}class="selected"{% endif %}>
                <a href="{% url "dashboard" %}">个人中心</a>
            </li>
            <li {% if section == "images" %}class="selected"{% endif %}>
                <a href="{% url "images:list" %}">照片</a>
            </li>
            <li {% if section == "people" %}class="selected"{% endif %}>
                <a href="{% url "user_list" %}">社区</a>
            </li>
        </ul>
    {% endif %}
    <span class="user">
        {% if request.user.is_authenticated %}
            {{ request.user.first_name }}
            <a href="{% url "logout" %}">注销</a>
        {% else %}
            <a href="{% url "login" %}">登陆</a>
        {% endif %}
    </span>
</div>
{% if messages %}
    <ul class="messages">
        {% for message in messages %}
            <li class="{{ message.tags }}">
                {{ message|safe }}
                <a href="#" class="close">×</a>
            </li>
        {% endfor %}
    </ul>
{% endif %}
<div id="content">
    {% block content %}
    {% endblock %}
</div>

<script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
<script src="http://cdn.jsdelivr.net/jquery.cookie/1.4.1/jquery.cookie.min.js"></script>
<script>
    // 读取 csrftoken cookie
    var csrftoken = $.cookie('csrftoken');

    function csrfSafeMethod(method) {
        // 这些HTTP方法不需要CSRF保护
        return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
    }

    $.ajaxSetup({
        beforeSend: function (xhr, settings) {
            if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
                xhr.setRequestHeader("X-CSRFToken", csrftoken);
            }
        }
    });

    $(document).ready(function () {
        {% block domready %}
        {% endblock %}
    });
</script>

</body>
</html>